<extend name="Public/base" />

<block name="body">
    <div class="main-title">
        <h2>推送模板列表</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn btn-default" href="{:U('Pushed/add')}">新 增</a>
        </div>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="title" class="search-input" value="{:I('title')}" placeholder="请输入模板标题">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>

    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="table table-hover">
            <thead>
            <tr>
                <th style="width: 8%">ID</th>
                <th style="width: 25%">模板标题</th>
                <th style="width: 10%">模板简码</th>
                <th style="width: 15%">发布时间</th>
                <th style="width: 5%">状态</th>
                <th style="width: 5%">预览</th>
                <th style="width: 20%">操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td>{$vo.id} </td>
                        <td><a href="{:U('Pushed/edit?id='.$vo['id'])}">{$vo.title}</a></td>
                        <td>{$vo.bin} </td>
                        <td>{$vo.createAt|time_format}</td>
                        <td>{$vo.status_text}</td>
                        <td>
                            <button type="button" onClick="test(event)">预览</button>
                        </td>
                        <td>
                            <a href="{:U('Pushed/del?id='.$vo['id'])}" class="confirm ajax-get  btn btn-warning">删除</a>
                            <a href="{:U('Pushed/test?id='.$vo['id'].'&bin='.$vo['bin'])}" class="btn btn-primary">测试</a>
                            <a href="{:U('Pushed/conversion?id='.$vo['id'])}" class="btn btn-info">转化</a>
                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>

    <div class="modal fade" id="myModal" tabindex="－1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content" style="margin-top: 100px;width: 302px;">
                <div id="qrcode" ></div>
            </div>
        </div>
    </div>

</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>


    <script type="text/javascript">
        function test(event)
        {
            event = event ? event : window.event;
            var obj = event.srcElement ? event.srcElement : event.target;
            $(obj).attr({"disabled":"disabled"});
            var gjz=$("td:eq(2)",$(obj).parents("tr")).text();

            var u = "";
            u = "http://wxshop.guoran100.com/index.php?s=/home/activity/pushpage/bin/"+gjz+".html";
            jQuery('#qrcode').qrcode({width: 300,height: 300,text: u});
            $('#myModal').modal('show');

        }

        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var query  = $('.search-form').find('input').serialize();
            var queryselect = $('.search-form').find('select').serialize();

            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            queryselect = queryselect.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            queryselect = queryselect.replace(/^&/g, '');

            if( url.indexOf('?')>0 ){
                url += '&' + query;
                url += '&' + queryselect;
            }else{
                url += '?' + query;
                url += '?' + queryselect;
            }
            window.location.href = url;
        });

        //回车搜索
        $(".search-input").keyup(function(e){
            if(e.keyCode === 13){
                $("#search").click();
                return false;
            }
        });

        //导航高亮
        highlight_subnav('{:U('Pushed/index')}');
    </script>
</block>
